home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / aie8911.zip / TALK < prev    next >
Text File  |  1989-07-30  |  5KB  |  309 lines

  1.  
  2.                        AI_SL/1
  3.     AI IN THE SYSTEM LIFECYCLE
  4.  
  5. 1.  DEBUGGING
  6.  
  7. 2.  SPECIFICATION
  8.  
  9. Today's talk restricted to
  10.     procedural systems
  11.  
  12.  
  13.                        AI_SL/2
  14.       DEBUGGING
  15.  
  16. * 2 SUBPROBLEMS:
  17.  
  18.   LOCATING THE BUG
  19.   FIXING IT
  20.  
  21.   -- ONLY TALK ABOUT LOCATING TODAY
  22.  
  23. LOCATION METHOD:
  24.  
  25.   1. PUT IN SIGNPOSTS
  26.  
  27.   2. RUN PROGRAM
  28.  
  29.   3.  LOOK AT TRACE MESSAGES
  30.      SHOWING EXECUTION TRAIL
  31.  
  32.  
  33.                        AI_SL/3
  34.  
  35. PROGRAMS THAT STOP WHEN THEY
  36. FAIL ARE EASY LOCATE ERROR
  37. REGION IN
  38.  
  39. * Put in signposts thru prog.
  40.   Get notices as program runs.
  41.  
  42. * When program stops,
  43.   this output stops.
  44.  
  45. * Look at the end of the trace
  46.   output to see where failure
  47.   stops the program.
  48.  
  49. Now, an example:
  50.  
  51.  
  52.                        AI_SL/4
  53.  
  54. * PROLOG MAKES STOP AT FAILURE EASY
  55.  
  56. * BUT WE CAN ALSO DO IT IN PASCAL
  57.  
  58.    -- see listing on machine
  59.  
  60.  
  61.                        AI_SL/5
  62.  
  63. * SIGNPOST DEBUGGING IS SUCCESSIVE
  64.   REFINEMENT
  65.  
  66. -- HAVE TO LOCATE PART OF PROGRAM
  67.    TO PUT IN SIGNPOSTS
  68.  
  69.  
  70.                        AI_SL/6
  71.  
  72.   DIVIDE AND CONQUER STRATEGY
  73.  
  74. 1.  Find out what part of prog.
  75.     bug is in.
  76.  
  77. 2.  Repeat process on that part.
  78.  
  79. 3.  Continue until you have the
  80.     bug confined to a little
  81.     section of code.
  82.  
  83. 4.  Recognize it.
  84.  
  85.  
  86.                        AI_SL/7
  87.  
  88. * D & C WITH THE COMPUTER:
  89.  
  90. -- THE COMPUTER DOES WHAT YOU DO
  91.  
  92. 1.  Run program with a system
  93.     module that saves info.
  94.  
  95. 2.  Let an expert system analyze
  96.     this info from the run.
  97.  
  98. 3.  Have the expert system decide
  99.     what part of the prog. has
  100.     the bug.
  101.  
  102. 4.  Repeat process on that part.
  103.  
  104. 5.  Continue until you have the
  105.     bug confined to a little
  106.     section of code.
  107.  
  108. 6.  Produce a report for the
  109.     user.
  110.  
  111.  
  112.                        AI_SL/8
  113.  
  114. IMPLEMENTATION OF THIS IN PROLOG
  115.  
  116. -- FIRST, A DEMO ON A BUGGY PROGRAM:
  117.  
  118. integers( []) :- !,
  119.                  fail.
  120. integers( [H|T]) :-
  121.     integer(H),
  122.     integers(T).
  123.  
  124. HOW WE DID THIS:
  125.  
  126. * ONE LEVEL AT A TIME
  127.  
  128. * FIND FAILING CALL IN EACH
  129.   PROCEDURE BODY
  130.  
  131. * THEN DO THE SAME ON THE BODY
  132.   OF THE CALLED PROCEDURE
  133.  
  134.  
  135.                        AI_SL/9
  136.  
  137. WHAT TO DO AT EACH LEVEL:
  138.  
  139. 1.  GET RULES OF FAILING PREDICATE
  140.  
  141. 2.  RUN PREDICATE, OBSERVING HOW
  142.     EACH RULE DOES:
  143.  
  144. FRAME subgoal_result
  145. call : integers([1])
  146. clause_no : 1
  147. head_matched : fail
  148. END_FRAME
  149.  
  150. FRAME subgoal_result
  151. call : integers([1])
  152. clause_no : 2
  153. result : fail
  154. failing_subgoal_number : 2
  155. failing_subgoal : integers([])
  156. head_matched : true
  157. END_FRAME
  158.  
  159. (see code on machine)
  160.  
  161.  
  162.                        AI_SL/10
  163.  
  164. CONDENSE THIS INTO A SUMMARY OF
  165.    WHAT HAPPENED FOR THE PREDICATE
  166.    AS A WHOLE:
  167.  
  168.  
  169. FRAME goal_report
  170. call : integers([1])
  171. clause_no : 2
  172. result : fail
  173. failing_subgoal_number : 2
  174. failing_subgoal : integers([])
  175. END_FRAME
  176.  
  177. -- see example rule on machine
  178.  
  179.  
  180.                        AI_SL/11
  181.  
  182. * DRIVE ANALYSIS DOWN A LEVEL
  183.  
  184. -- AS LONG AS REPORT AT PREV.
  185.    LEVEL SAYS WHERE TO GO
  186.  
  187. -- see code on machine:
  188.  
  189.  
  190.                        AI_SL/12
  191.  
  192. THIS PRODUCES THE BUG INFO:
  193.  
  194. [  % start of bug path list
  195.   [  % start of first bug path
  196.    goal_report([
  197.      system_predicate : true,
  198.      result : fail,
  199.      call : fail,
  200.      reason : $You called fail$]),
  201.  
  202.    goal_report([
  203.      call : integers([]),
  204.      clause_no : 1,
  205.      result : fail,
  206.      failing_subgoal_number : 2,
  207.      failing_subgoal : fail,
  208.      cuts_passed : 1 ]),
  209.  
  210.    goal_report([
  211.      call : integers([1]),
  212.      clause_no : 2,
  213.      result : fail,
  214.      failing_subgoal_number : 2,
  215.      failing_subgoal : integers([]) ]),
  216.  
  217.    goal_report([
  218.     failing_subgoal : integers([1])
  219.     source : user  ])
  220.   ]  % end of only bug path
  221. ]  % end of bug path list
  222.  
  223.  
  224.                        AI_SL/13
  225.  
  226. THIS GETS TRANSLATED INTO A REPORT:
  227.  
  228. HERE IS THE BUG ANALYSIS :
  229.  
  230. THE TOP LEVEL BUG...
  231.  
  232.      The user-supplied goal
  233.      integers([1]) failed.
  234.  
  235.  
  236. GOING DOWN A LEVEL,
  237.  
  238.   The goal at this level is
  239.   integers([1]) which failed.
  240.  
  241.   Clause 2 of integers / 1 failed.
  242.  
  243.   Here it is with the failing
  244.    subgoal marked.
  245.  
  246.   integers([A|B]) :-
  247.         integer(A),
  248. FAILS==>integers(B).
  249.  
  250.   Instantiated, this subgoal
  251.    is integers([]).
  252.  
  253.  
  254.                        AI_SL/14
  255.  
  256. REPORT, CONT.
  257.  
  258.  
  259. GOING DOWN A LEVEL,
  260.  
  261.   The goal at this level is
  262.   integers([]) which failed.
  263.  
  264.   Clause 1 of integers / 1 failed.
  265.  
  266.   Here it is with the failing
  267.    subgoal marked.
  268.  
  269.   integers([]) :-
  270.         !,
  271. FAILS==>fail.
  272.  
  273.   Instantiated, this subgoal is
  274.     fail.
  275.  
  276.  
  277. GOING DOWN A LEVEL,
  278.  
  279.   You deliberately called
  280.     the predicate 'fail'.
  281.  
  282.  
  283.  -- ( end of this particular
  284.     possible bug explanation ) --
  285.  
  286.  
  287.                        AI_SL/15
  288.  
  289. OBSERVATIONS:
  290.  
  291. * FRAMES ARE VERY USEFUL TO HOLD
  292.   WHAT YOU LEARN
  293.  
  294. * FRAMES FIT INTO PROLOG --
  295.   UNIFICATION EXTENDS TO FRAMES
  296.  
  297. * LOTS OF LITTLE EXPERT SYSTEMS
  298.   MODULARIZE THE PROBLEM
  299.  
  300.     Used here:
  301.   -- single rule behavior
  302.   -- single predicate behavior
  303.   -- when to extend analysis
  304.   -- report production
  305.  
  306.  
  307.  
  308.  
  309.